package com.weareint.common.jpabase;


import lombok.Data;


/**
 *
 *
 * <pre>
 *      ResultVoUtil
 * </pre>
 *
 * @author Johnny
 * @date 2021-09-28
 */
@Data
public class ResultVoUtil {

    public static <T> ResultVo<T> success(T data) {
        ResultVo<T> resultVO = new ResultVo<>();
        resultVO.setData(data);
        resultVO.setCode(200);
        resultVO.setMsg("success");
        return resultVO;
    }

    public static ResultVo<Void> success() {
        return success(null);
    }

    public static ResultVo expire() {
        ResultVo expireResultVo = new ResultVo();
        expireResultVo.setCode(50008);
        expireResultVo.setMsg("success");
        return expireResultVo;
    }

    public static ResultVo loginFail() {
        ResultVo expireResultVo = new ResultVo();
        expireResultVo.setCode(40000);
        expireResultVo.setMsg("账号或密码错误!");
        return expireResultVo;
    }

    public static ResultVo tokenError() {
        ResultVo expireResultVo = new ResultVo();
        expireResultVo.setCode(40000);
        expireResultVo.setMsg("Token错误!");
        return expireResultVo;
    }

    public static ResultVo noLogin() {
        ResultVo expireResultVo = new ResultVo();
        expireResultVo.setCode(40000);
        expireResultVo.setMsg("用户未登录");
        return expireResultVo;
    }


    public static ResultVo accessReject() {
        ResultVo expireResultVo = new ResultVo();
        expireResultVo.setCode(50403);
        expireResultVo.setMsg("无权访问资源!");
        return expireResultVo;
    }


    public static ResultVo logOut() {
        ResultVo logOutResultVo = new ResultVo();
        logOutResultVo.setCode(50012);
        logOutResultVo.setMsg("success");
        return logOutResultVo;
    }


    public static ResultVo error(Integer code, String msg) {
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }


    public static ResultVo error(String msg) {
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(500);
        resultVO.setMsg(msg);
        return resultVO;
    }

}
